/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * DatosEcoestresPanel.java
 *
 * Created on 17/01/2011, 17:20:58
 */

package presentacion.examen;

import hibernate.objeto.ErgometriaEstudioCardiologia;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import javax.swing.JDialog;
import javax.swing.JSpinner.DefaultEditor;
import logica.CapaLogica;
import logica.validacion.CapaValidacion;
import presentacion.CapaPresentacion;
import presentacion.utilidad.maquetado.Fuente;
import presentacion.utilidad.maquetado.InformeError;

/**
 *
 * @author Gonzalo
 */
public class DatosErgometriaPanel extends javax.swing.JPanel {

    /** Creates new form DatosEcoestresPanel */
    public DatosErgometriaPanel() {
        initComponents();
        setearEventosQueCapturanTeclaEnterYEscape();
    }

    /**
     * Setea datos de la ventana.
     *
     */
    public void personalizarJDialog(ErgometriaEstudioCardiologia 
            ergometriaEstudioCardiologia) {
        this.ergometriaEstudioCardiologia =
                ergometriaEstudioCardiologia;
        exhibirDatosEnPantalla();
        if(CapaPresentacion.modoVisualizacion) {
            inhabilitarCampos();
        }
    }

    /**
     * Permite visualizar los detalles de la evolución.
     *
     */
    private void exhibirDatosEnPantalla() {        
        metodoErgonometria.getModel().setSelectedItem(
                ergometriaEstudioCardiologia.
                getMetodoErgometriaEstudioCardiologia());
        protocoloErgonometria.getModel().setSelectedItem(
                ergometriaEstudioCardiologia.
                getProtocoloErgometriaEstudioCardiologia());
        tensionArterialBasalDiastolicaErgonometria.setValue(
                ergometriaEstudioCardiologia.
                getTensionArterialBasalDiastolicaErgometriaEstudioCardiologi());
        tensionArterialBasalSistolicaErgonometria.setValue(
                ergometriaEstudioCardiologia.
                getTensionArterialBasalSistolicaErgometriaEstudioCardiologia());
        tensionArterialMaximoEsfuerzoBasalDiastolicaErgonometria.setValue(
                ergometriaEstudioCardiologia.
                getTensionArterialMaximoEsfuerzoDiastolicaErgometriaEstudio());
        tensionArterialMaximoEsfuerzoBasalSistolicaErgonometria.setValue(
                ergometriaEstudioCardiologia.
                getTensionArterialMaximoEsfuerzoSistolicaErgometriaEstudioC());
        if (ergometriaEstudioCardiologia.getAngorErgometriaEstudioCardiologia().
                equalsIgnoreCase("si")) {
            siAngorErgonometria.setSelected(true);
            noAngorErgonometria.setSelected(false);
        } else {
            siAngorErgonometria.setSelected(false);
            noAngorErgonometria.setSelected(true);
        }
        segmentoSTErgonometria.setValue(
                ergometriaEstudioCardiologia.
                getSegmentoStErgometriaEstudioCardiologia());
        fCBasalErgonometria.setValue(
                ergometriaEstudioCardiologia.
                getFcBasalErgometriaEstudioCardiologia());
        fCMaximoEsfuerzoErgonometria.setValue(
                ergometriaEstudioCardiologia.
                getFcMaximoEsfuerzoErgometriaEstudioCardiologia());
        valoresMaximoEsfuerzoErgonometria.setValue(
                ergometriaEstudioCardiologia.
                getValorMaximoEsfuerzoErgometriaEstudioCardiologia());
        unidadesMaximoEsfuerzoErgonometria.setText(
                ergometriaEstudioCardiologia.
                getUnidadesMaximoEsfuerzoErgometriaEstudioCardiologia());
        unidadesMaximoEsfuerzoErgonometria.setCaretPosition(0);
    }

    /**
     * Pone en false la propiedad enabled de todos los campos de ingreso.
     *
     */
    private void inhabilitarCampos() {
        metodoErgonometria.setEnabled(false);
        protocoloErgonometria.setEnabled(false);
        tensionArterialBasalDiastolicaErgonometria.setEnabled(false);
        tensionArterialBasalSistolicaErgonometria.setEnabled(false);
        tensionArterialMaximoEsfuerzoBasalDiastolicaErgonometria.setEnabled(false);
        tensionArterialMaximoEsfuerzoBasalSistolicaErgonometria.setEnabled(false);
        siAngorErgonometria.setEnabled(false);
        noAngorErgonometria.setEnabled(false);
        siAngorErgonometria.setSelected(false);
        noAngorErgonometria.setSelected(true);
        segmentoSTErgonometria.setEnabled(false);
        fCBasalErgonometria.setEnabled(false);
        fCMaximoEsfuerzoErgonometria.setEnabled(false);
        valoresMaximoEsfuerzoErgonometria.setEnabled(false);
        unidadesMaximoEsfuerzoErgonometria.setEnabled(false);
    }

    /**
     * Valida en conjunto todos los campos. Aquellos que son obligatorios y los
     * que no.
     *
     * @return true si el objeto está listo para cargarse, false en caso
     * contrario
     */
    public boolean validarCampos() {
        boolean esMetodoValida = validarCampoMetodo();
        boolean esProtocoloValida = validarCamposProtocolo();
        boolean esAngorValida = validarCamposAngor();
        boolean esUnidadesMaximoEsfuerzoValida =
                unidadesCamposUnidadesMaximoEsfuerzo();

        return esMetodoValida && esAngorValida &&
                esProtocoloValida && esUnidadesMaximoEsfuerzoValida;
    }

    /**
     * Valida los campos correspondiente al campo Metodo.
     *
     * @return true si los campos estan listos para cargarse, false en caso
     * contrario
     */
    private boolean validarCampoMetodo() {
        boolean retorno;

        if (!CapaValidacion.validarCampoObligatorio(metodoErgonometria.
                getSelectedItem().toString())) {
            textoMetodoErgonometria.setForeground(
                    Fuente.COLOR_ERROR);
            textoMetodoErgonometria.setToolTipText(
                    InformeError.
                    INFORME_ERROR_CARDIOLOGICO_ERGONOMETRIA_METODO);
            retorno = false;
        } else {
            textoMetodoErgonometria.setForeground(Fuente.COLOR_NORMAL);
            textoMetodoErgonometria.setToolTipText(null);
            retorno = true;
        }

        return retorno;
    }

    /**
     * Valida los campos correspondiente al campo Protocolo.
     *
     * @return true si los campos estan listos para cargarse, false en caso
     * contrario
     */
    private boolean validarCamposProtocolo() {
        boolean retorno;

        if (!CapaValidacion.validarCampoObligatorio(protocoloErgonometria.
                getSelectedItem().toString())) {
            textoProtocoloErgonometria.setForeground(
                    Fuente.COLOR_ERROR);
            textoProtocoloErgonometria.setToolTipText(
                    InformeError.
                    INFORME_ERROR_CARDIOLOGICO_ERGONOMETRIA_PROTOCOLO);
            retorno = false;
        } else {
            textoProtocoloErgonometria.setForeground(Fuente.COLOR_NORMAL);
            textoProtocoloErgonometria.setToolTipText(null);
            retorno = true;
        }

        return retorno;
    }

    /**
     * Valida los campos correspondiente al campo Angor.
     *
     * @return true si los campos estan listos para cargarse, false en caso
     * contrario
     */
    private boolean validarCamposAngor() {
        boolean retorno;

        if (!siAngorErgonometria.isSelected() &&
                !noAngorErgonometria.isSelected()) {
            textoAngorErgonometria.setForeground(
                    Fuente.COLOR_ERROR);
            textoAngorErgonometria.setToolTipText(
                    InformeError.
                    INFORME_ERROR_CARDIOLOGICO_ECOESTRESS_ANGOR);
            retorno = false;
        } else {
            textoAngorErgonometria.setForeground(Fuente.COLOR_NORMAL);
            textoAngorErgonometria.setToolTipText(null);
            retorno = true;
        }

        return retorno;
    }

    /**
     * Valida los campos correspondiente al campo unidades de maximo esfuerzo.
     *
     * @return true si los campos estan listos para cargarse, false en caso
     * contrario
     */
    private boolean unidadesCamposUnidadesMaximoEsfuerzo() {
        boolean retorno;

        if (!CapaValidacion.validarCampoObligatorio(
                unidadesMaximoEsfuerzoErgonometria.getText())) {
            textoUnidadesMaximoEsfuerzoErgonometria.setForeground(
                    Fuente.COLOR_ERROR);
            textoUnidadesMaximoEsfuerzoErgonometria.setToolTipText(
                    InformeError.
                    INFORME_ERROR_CARDIOLOGICO_ECOESTRESS_UNIDADES_MAXIMO_ESFUERZO);
            retorno = false;
        } else {
            textoUnidadesMaximoEsfuerzoErgonometria.setForeground(Fuente.COLOR_NORMAL);
            textoUnidadesMaximoEsfuerzoErgonometria.setToolTipText(null);
            retorno = true;
        }

        return retorno;
    }

    /**
     * Recopila los datos del panel para colocarlos dentro del arreglo.
     *
     * @param datosEstudioCardiologia El arreglo a cargar
     */
    public void recopilarDatos(Object[] datosEstudioCardiologia) {

        if (siAngorErgonometria.isSelected()) {
            datosEstudioCardiologia[CapaLogica.ESTUDIO_CARDIOLOGIA_ERGOMETRIA_ANGOR] =
                "si";
        } else {
            datosEstudioCardiologia[CapaLogica.ESTUDIO_CARDIOLOGIA_ERGOMETRIA_ANGOR] =
                "no";
        }
        datosEstudioCardiologia[CapaLogica.
                ESTUDIO_CARDIOLOGIA_ERGOMETRIA_FC_BASAL] =
                fCBasalErgonometria.getValue();
        datosEstudioCardiologia[CapaLogica.
                ESTUDIO_CARDIOLOGIA_ERGOMETRIA_FC_MAXIMO_ESFUERZO] =
                fCMaximoEsfuerzoErgonometria.getValue();
        datosEstudioCardiologia[CapaLogica.ESTUDIO_CARDIOLOGIA_ERGOMETRIA_METODO] =
                metodoErgonometria.getSelectedItem();
        datosEstudioCardiologia[CapaLogica.ESTUDIO_CARDIOLOGIA_ERGOMETRIA_PROTOCOLO] =
                protocoloErgonometria.getSelectedItem();
        datosEstudioCardiologia[CapaLogica.ESTUDIO_CARDIOLOGIA_ERGOMETRIA_SEGMENTO_ST] =
                segmentoSTErgonometria.getValue();
        datosEstudioCardiologia[CapaLogica.ESTUDIO_CARDIOLOGIA_ERGOMETRIA_TENSION_ARTERIAL_BASAL_DIASTOLICA] =
                tensionArterialBasalDiastolicaErgonometria.getValue();
        datosEstudioCardiologia[CapaLogica.ESTUDIO_CARDIOLOGIA_ERGOMETRIA_TENSION_ARTERIAL_BASAL_SISTOLICA] =
                tensionArterialBasalSistolicaErgonometria.getValue();
        datosEstudioCardiologia[CapaLogica.
                ESTUDIO_CARDIOLOGIA_ERGOMETRIA_TENSION_ARTERIAL_MAXIMO_ESFUERZO_DIASTOLICA] =
                tensionArterialMaximoEsfuerzoBasalDiastolicaErgonometria.getValue();
        datosEstudioCardiologia[CapaLogica.
                ESTUDIO_CARDIOLOGIA_ERGOMETRIA_TENSION_ARTERIAL_MAXIMO_ESFUERZO_SISTOLICA] =
                tensionArterialMaximoEsfuerzoBasalSistolicaErgonometria.getValue();
        datosEstudioCardiologia[CapaLogica.
                ESTUDIO_CARDIOLOGIA_ERGOMETRIA_MAXIMO_ESFUERZO_UNIDADES] =
                unidadesMaximoEsfuerzoErgonometria.getText();
        datosEstudioCardiologia[CapaLogica.
                ESTUDIO_CARDIOLOGIA_ERGOMETRIA_MAXIMO_ESFUERZO_VALOR] =
                valoresMaximoEsfuerzoErgonometria.getValue();

    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        textoMetodoErgonometria = new javax.swing.JLabel();
        textoFCBasalErgonometria = new javax.swing.JLabel();
        textoFCMaximoEsfuerzoErgonometria = new javax.swing.JLabel();
        tensionArterialMaximoEsfuerzoBasalSistolicaErgonometria = new javax.swing.JSpinner();
        textoTensionArterialMaximoEsfuerzoBasalSistolicaErgonometria = new javax.swing.JLabel();
        textoTensionArterialBasalDiastolicaErgonometria = new javax.swing.JLabel();
        textoProtocoloErgonometria = new javax.swing.JLabel();
        tensionArterialBasalDiastolicaErgonometria = new javax.swing.JSpinner();
        textoTensionArterialBasalSistolicaErgonometria = new javax.swing.JLabel();
        textoAngorErgonometria = new javax.swing.JLabel();
        tensionArterialBasalSistolicaErgonometria = new javax.swing.JSpinner();
        tensionArterialMaximoEsfuerzoBasalDiastolicaErgonometria = new javax.swing.JSpinner();
        textoTensionArterialMaximoEsfuerzoBasalDiastolicaErgonometria = new javax.swing.JLabel();
        textoSegmentoSTErgonometria = new javax.swing.JLabel();
        segmentoSTErgonometria = new javax.swing.JSpinner();
        siAngorErgonometria = new javax.swing.JRadioButton();
        noAngorErgonometria = new javax.swing.JRadioButton();
        metodoErgonometria = new javax.swing.JComboBox();
        protocoloErgonometria = new javax.swing.JComboBox();
        fCBasalErgonometria = new javax.swing.JSpinner();
        fCMaximoEsfuerzoErgonometria = new javax.swing.JSpinner();
        textoValoresMaximoEsfuerzoErgonometria = new javax.swing.JLabel();
        valoresMaximoEsfuerzoErgonometria = new javax.swing.JSpinner();
        textoUnidadesMaximoEsfuerzoErgonometria = new javax.swing.JLabel();
        unidadesMaximoEsfuerzoErgonometria = new javax.swing.JTextField();

        textoMetodoErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        textoMetodoErgonometria.setText("Método");
        textoMetodoErgonometria.setPreferredSize(new java.awt.Dimension(233, 20));

        textoFCBasalErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        textoFCBasalErgonometria.setText("FC basal");
        textoFCBasalErgonometria.setPreferredSize(new java.awt.Dimension(233, 20));

        textoFCMaximoEsfuerzoErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        textoFCMaximoEsfuerzoErgonometria.setText("FC máximo esfuerzo");
        textoFCMaximoEsfuerzoErgonometria.setPreferredSize(new java.awt.Dimension(233, 20));

        tensionArterialMaximoEsfuerzoBasalSistolicaErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        tensionArterialMaximoEsfuerzoBasalSistolicaErgonometria.setModel(new javax.swing.SpinnerNumberModel());
        tensionArterialMaximoEsfuerzoBasalSistolicaErgonometria.setPreferredSize(new java.awt.Dimension(70, 20));

        textoTensionArterialMaximoEsfuerzoBasalSistolicaErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        textoTensionArterialMaximoEsfuerzoBasalSistolicaErgonometria.setText("Tensión arterial máximo esfuerzo basal sistólica");
        textoTensionArterialMaximoEsfuerzoBasalSistolicaErgonometria.setPreferredSize(new java.awt.Dimension(233, 20));

        textoTensionArterialBasalDiastolicaErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        textoTensionArterialBasalDiastolicaErgonometria.setText("Tensión arterial basal diastólica");
        textoTensionArterialBasalDiastolicaErgonometria.setPreferredSize(new java.awt.Dimension(233, 20));

        textoProtocoloErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        textoProtocoloErgonometria.setText("Protocolo");
        textoProtocoloErgonometria.setPreferredSize(new java.awt.Dimension(233, 20));

        tensionArterialBasalDiastolicaErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        tensionArterialBasalDiastolicaErgonometria.setModel(new javax.swing.SpinnerNumberModel());
        tensionArterialBasalDiastolicaErgonometria.setPreferredSize(new java.awt.Dimension(70, 20));

        textoTensionArterialBasalSistolicaErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        textoTensionArterialBasalSistolicaErgonometria.setText("Tensión arterial basal sistólica");
        textoTensionArterialBasalSistolicaErgonometria.setPreferredSize(new java.awt.Dimension(233, 20));

        textoAngorErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        textoAngorErgonometria.setText("Angor");
        textoAngorErgonometria.setMinimumSize(new java.awt.Dimension(225, 20));
        textoAngorErgonometria.setPreferredSize(new java.awt.Dimension(233, 20));

        tensionArterialBasalSistolicaErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        tensionArterialBasalSistolicaErgonometria.setModel(new javax.swing.SpinnerNumberModel());
        tensionArterialBasalSistolicaErgonometria.setPreferredSize(new java.awt.Dimension(70, 20));

        tensionArterialMaximoEsfuerzoBasalDiastolicaErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        tensionArterialMaximoEsfuerzoBasalDiastolicaErgonometria.setModel(new javax.swing.SpinnerNumberModel());
        tensionArterialMaximoEsfuerzoBasalDiastolicaErgonometria.setPreferredSize(new java.awt.Dimension(70, 20));

        textoTensionArterialMaximoEsfuerzoBasalDiastolicaErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        textoTensionArterialMaximoEsfuerzoBasalDiastolicaErgonometria.setText("Tensión arterial máximo esfuerzo basal diastólica");
        textoTensionArterialMaximoEsfuerzoBasalDiastolicaErgonometria.setPreferredSize(new java.awt.Dimension(233, 20));

        textoSegmentoSTErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        textoSegmentoSTErgonometria.setText("Segmento ST (mm)");
        textoSegmentoSTErgonometria.setPreferredSize(new java.awt.Dimension(233, 20));

        segmentoSTErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        segmentoSTErgonometria.setModel(new javax.swing.SpinnerNumberModel(Float.valueOf(0.0f), null, null, Float.valueOf(1.0f)));
        segmentoSTErgonometria.setPreferredSize(new java.awt.Dimension(70, 20));

        siAngorErgonometria.setFont(Fuente.FUENTE_CHECKBOX);
        siAngorErgonometria.setForeground(Fuente.COLOR_NORMAL);
        siAngorErgonometria.setText("si");
        siAngorErgonometria.setPreferredSize(new java.awt.Dimension(42, 20));
        siAngorErgonometria.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                siAngorErgonometriaActionPerformed(evt);
            }
        });

        noAngorErgonometria.setFont(Fuente.FUENTE_CHECKBOX);
        noAngorErgonometria.setForeground(Fuente.COLOR_NORMAL);
        noAngorErgonometria.setText("no");
        noAngorErgonometria.setPreferredSize(new java.awt.Dimension(42, 20));
        noAngorErgonometria.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                noAngorErgonometriaActionPerformed(evt);
            }
        });

        metodoErgonometria.setFont(Fuente.FUENTE_COMBOBOX);
        metodoErgonometria.setModel(CapaPresentacion.getListaDeTipoMetodoErgonometriaEstudioCardiologia());
        metodoErgonometria.setPreferredSize(new java.awt.Dimension(111, 20));

        protocoloErgonometria.setFont(Fuente.FUENTE_COMBOBOX);
        protocoloErgonometria.setModel(CapaPresentacion.getListaDeTipoProtocoloErgonometriaEstudioCardiologia());
        protocoloErgonometria.setPreferredSize(new java.awt.Dimension(111, 20));

        fCBasalErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        fCBasalErgonometria.setModel(new javax.swing.SpinnerNumberModel());
        fCBasalErgonometria.setPreferredSize(new java.awt.Dimension(70, 20));

        fCMaximoEsfuerzoErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        fCMaximoEsfuerzoErgonometria.setModel(new javax.swing.SpinnerNumberModel());
        fCMaximoEsfuerzoErgonometria.setPreferredSize(new java.awt.Dimension(70, 20));

        textoValoresMaximoEsfuerzoErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        textoValoresMaximoEsfuerzoErgonometria.setText("Valor máximo esfuerzo");
        textoValoresMaximoEsfuerzoErgonometria.setPreferredSize(new java.awt.Dimension(223, 20));

        valoresMaximoEsfuerzoErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        valoresMaximoEsfuerzoErgonometria.setModel(new javax.swing.SpinnerNumberModel());
        valoresMaximoEsfuerzoErgonometria.setPreferredSize(new java.awt.Dimension(70, 20));

        textoUnidadesMaximoEsfuerzoErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        textoUnidadesMaximoEsfuerzoErgonometria.setText("Unidades máximo esfuerzo (Mets/Kgm)");
        textoUnidadesMaximoEsfuerzoErgonometria.setPreferredSize(new java.awt.Dimension(223, 20));

        unidadesMaximoEsfuerzoErgonometria.setFont(Fuente.FUENTE_TEXTFIELD);
        unidadesMaximoEsfuerzoErgonometria.setPreferredSize(new java.awt.Dimension(70, 20));

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addComponent(textoUnidadesMaximoEsfuerzoErgonometria, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(textoValoresMaximoEsfuerzoErgonometria, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(textoMetodoErgonometria, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(textoProtocoloErgonometria, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(textoTensionArterialBasalSistolicaErgonometria, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(textoTensionArterialBasalDiastolicaErgonometria, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(textoTensionArterialMaximoEsfuerzoBasalSistolicaErgonometria, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(textoTensionArterialMaximoEsfuerzoBasalDiastolicaErgonometria, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(textoFCMaximoEsfuerzoErgonometria, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(textoFCBasalErgonometria, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(textoSegmentoSTErgonometria, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addComponent(textoAngorErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(fCBasalErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(fCMaximoEsfuerzoErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(valoresMaximoEsfuerzoErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(unidadesMaximoEsfuerzoErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tensionArterialMaximoEsfuerzoBasalSistolicaErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tensionArterialBasalDiastolicaErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tensionArterialBasalSistolicaErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(protocoloErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(metodoErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(siAngorErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(noAngorErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(tensionArterialMaximoEsfuerzoBasalDiastolicaErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(segmentoSTErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(16, 16, 16))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textoMetodoErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(metodoErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textoProtocoloErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(protocoloErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textoTensionArterialBasalSistolicaErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tensionArterialBasalSistolicaErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textoTensionArterialBasalDiastolicaErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tensionArterialBasalDiastolicaErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textoTensionArterialMaximoEsfuerzoBasalSistolicaErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tensionArterialMaximoEsfuerzoBasalSistolicaErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textoTensionArterialMaximoEsfuerzoBasalDiastolicaErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(tensionArterialMaximoEsfuerzoBasalDiastolicaErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textoAngorErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(siAngorErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(noAngorErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textoSegmentoSTErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(segmentoSTErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textoFCBasalErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(fCBasalErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textoFCMaximoEsfuerzoErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(fCMaximoEsfuerzoErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textoValoresMaximoEsfuerzoErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(valoresMaximoEsfuerzoErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(textoUnidadesMaximoEsfuerzoErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(unidadesMaximoEsfuerzoErgonometria, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void siAngorErgonometriaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_siAngorErgonometriaActionPerformed
        if (siAngorErgonometria.isSelected()) {
            noAngorErgonometria.setSelected(false);
        }
}//GEN-LAST:event_siAngorErgonometriaActionPerformed

    private void noAngorErgonometriaActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_noAngorErgonometriaActionPerformed
        if (noAngorErgonometria.isSelected()) {
            siAngorErgonometria.setSelected(false);
        }
}//GEN-LAST:event_noAngorErgonometriaActionPerformed

    /**
     * Setea en cada componente del JDialog los eventos que capturarán la tecla
     * enter y escape.
     */
    private void setearEventosQueCapturanTeclaEnterYEscape() {
        //Declaración del evento a capturar
        KeyListener keyListenerEscape = new KeyAdapter() {
            public void keyPressed(java.awt.event.KeyEvent evt) {
                if (evt.getKeyCode() == KeyEvent.VK_ESCAPE) {
                    cerrarVentana();
                }
            }
        };

        //Setear eventos
        metodoErgonometria.addKeyListener(keyListenerEscape);
        protocoloErgonometria.addKeyListener(keyListenerEscape);
        ((DefaultEditor) tensionArterialBasalDiastolicaErgonometria.getEditor()).
                getTextField().addKeyListener(keyListenerEscape);
        ((DefaultEditor) tensionArterialBasalSistolicaErgonometria.getEditor()).
                getTextField().addKeyListener(keyListenerEscape);
        ((DefaultEditor) tensionArterialMaximoEsfuerzoBasalDiastolicaErgonometria.getEditor()).
                getTextField().addKeyListener(keyListenerEscape);
        ((DefaultEditor) tensionArterialMaximoEsfuerzoBasalSistolicaErgonometria.getEditor()).
                getTextField().addKeyListener(keyListenerEscape);
        siAngorErgonometria.addKeyListener(keyListenerEscape);
        noAngorErgonometria.addKeyListener(keyListenerEscape);
        ((DefaultEditor) segmentoSTErgonometria.getEditor()).
                getTextField().addKeyListener(keyListenerEscape);
        ((DefaultEditor) fCBasalErgonometria.getEditor()).
                getTextField().addKeyListener(keyListenerEscape);
        ((DefaultEditor) fCMaximoEsfuerzoErgonometria.getEditor()).
                getTextField().addKeyListener(keyListenerEscape);
        ((DefaultEditor) valoresMaximoEsfuerzoErgonometria.getEditor()).
                getTextField().addKeyListener(keyListenerEscape);
        unidadesMaximoEsfuerzoErgonometria.addKeyListener(keyListenerEscape);
    }

    private void cerrarVentana() {
        JDialog jdialog = (JDialog)
                this.getParent().getParent().getParent().getParent().
                getParent().getParent().getParent().getParent().
                getParent().getParent().getParent().getParent().getParent();
        jdialog.dispose();
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JSpinner fCBasalErgonometria;
    private javax.swing.JSpinner fCMaximoEsfuerzoErgonometria;
    private javax.swing.JComboBox metodoErgonometria;
    private javax.swing.JRadioButton noAngorErgonometria;
    private javax.swing.JComboBox protocoloErgonometria;
    private javax.swing.JSpinner segmentoSTErgonometria;
    private javax.swing.JRadioButton siAngorErgonometria;
    private javax.swing.JSpinner tensionArterialBasalDiastolicaErgonometria;
    private javax.swing.JSpinner tensionArterialBasalSistolicaErgonometria;
    private javax.swing.JSpinner tensionArterialMaximoEsfuerzoBasalDiastolicaErgonometria;
    private javax.swing.JSpinner tensionArterialMaximoEsfuerzoBasalSistolicaErgonometria;
    private javax.swing.JLabel textoAngorErgonometria;
    private javax.swing.JLabel textoFCBasalErgonometria;
    private javax.swing.JLabel textoFCMaximoEsfuerzoErgonometria;
    private javax.swing.JLabel textoMetodoErgonometria;
    private javax.swing.JLabel textoProtocoloErgonometria;
    private javax.swing.JLabel textoSegmentoSTErgonometria;
    private javax.swing.JLabel textoTensionArterialBasalDiastolicaErgonometria;
    private javax.swing.JLabel textoTensionArterialBasalSistolicaErgonometria;
    private javax.swing.JLabel textoTensionArterialMaximoEsfuerzoBasalDiastolicaErgonometria;
    private javax.swing.JLabel textoTensionArterialMaximoEsfuerzoBasalSistolicaErgonometria;
    private javax.swing.JLabel textoUnidadesMaximoEsfuerzoErgonometria;
    private javax.swing.JLabel textoValoresMaximoEsfuerzoErgonometria;
    private javax.swing.JTextField unidadesMaximoEsfuerzoErgonometria;
    private javax.swing.JSpinner valoresMaximoEsfuerzoErgonometria;
    // End of variables declaration//GEN-END:variables
    private ErgometriaEstudioCardiologia ergometriaEstudioCardiologia;
}
